{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "vm8vn9t8DvC_"
   },
   "source": [
    "# Near Blockchain"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "5WjXERXzFEhg"
   },
   "source": [
    "## Overview"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {
    "id": "juAmbgoWD17u"
   },
   "source": [
    "The intention of this notebook is to provide a means of testing functionality in the Langchain Document Loader for Near Blockchain.\n",
    "\n",
    "Initially this Loader supports:\n",
    "\n",
    "*   Loading NFTs as Documents from NFT Smart Contracts (NEP-171 and NEP-177)\n",
    "*   Near Mainnnet, Near Testnet (default is mainnet)\n",
    "*   Mintbase's Graph API\n",
    "\n",
    "It can be extended if the community finds value in this loader.  Specifically:\n",
    "\n",
    "*   Additional APIs can be added (e.g. Tranction-related APIs)\n",
    "\n",
    "This Document Loader Requires:\n",
    "\n",
    "*   A free [Mintbase API Key](https://docs.mintbase.xyz/dev/mintbase-graph/)\n",
    "\n",
    "The output takes the following format:\n",
    "\n",
    "- pageContent= Individual NFT\n",
    "- metadata={'source': 'nft.yearofchef.near', 'blockchain': 'mainnet', 'tokenId': '1846'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load NFTs into Document Loader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# get MINTBASE_API_KEY from https://docs.mintbase.xyz/dev/mintbase-graph/\n",
    "\n",
    "mintbaseApiKey = \"...\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Option 1: Ethereum Mainnet (default BlockchainType)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "J3LWHARC-Kn0"
   },
   "outputs": [],
   "source": [
    "from MintbaseLoader import MintbaseDocumentLoader\n",
    "\n",
    "contractAddress = \"nft.yearofchef.near\"  # Year of chef contract address\n",
    "\n",
    "\n",
    "blockchainLoader = MintbaseDocumentLoader(\n",
    "    contract_address=contractAddress, blockchain_type=\"mainnet\", api_key=\"omni-site\"\n",
    ")\n",
    "\n",
    "nfts = blockchainLoader.load()\n",
    "\n",
    "print(nfts[:1])\n",
    "\n",
    "for doc in blockchainLoader.lazy_load():\n",
    "    print()\n",
    "    print(type(doc))\n",
    "    print(doc)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [
    "5WjXERXzFEhg"
   ],
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
